/**
 * 
 */
package com.unlp.javaclickers.docente.modelo.dao.impl;

import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import com.googlecode.genericdao.dao.hibernate.GenericDAOImpl;
import com.googlecode.genericdao.search.Search;
import com.unlp.javaclickers.docente.modelo.dao.DocenteDAO;
import com.unlp.javaclickers.helper.HibernateUtil;
import com.unlp.javaclickers.modelo.Docente;

/**
 * @author Pablo
 * 
 */
public class DocenteDAOImpl extends GenericDAOImpl<Docente, Integer> implements
		DocenteDAO {

	public DocenteDAOImpl(SessionFactory sessionFactory) {
		super();
		this.setSessionFactory(sessionFactory);
	}

	@Override
	public Docente findByUser(String user) {
		Transaction transaction = HibernateUtil.getSessionFactory()
				.getCurrentSession().beginTransaction();
		Search busqueda = new Search();
		busqueda.addFilterEqual("usuario", user);
		Docente result = this.searchUnique(busqueda);

		transaction.commit();
		return result;

	}

}
